<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN">
<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<title>Collision detection</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>

<body>

<div align="center">
<table class=allEncompassingTable >
 <tr>
  <td >
<p><a href="../index.html" TARGET="_top"><img src="images/homeImg.png"></a></p>



<h1>Collision detection</h1>


<p>CoppeliaSim can detect collisions between two <a href="collidableObjects.htm">collidable</a> <a href="entities.htm">entities</a> in a very flexible way. The calculation is an exact interference calculation. The collision detection module will only detect collisions; it does however not directly react to them (for collision response, refer to the <a href="dynamicsModule.htm">dynamics module</a>). Following figure illustrates the collision detection functionality:<br>
  <br>
</p>

<p align=center><img src="images/collisionDetection1.jpg"></p>
<p class=imageLabel>[(1) Simple collision detection between two manipulators, (2) Exhaustive collision detection between two shapes]</p>
<br>

<p>The collision detection module allows registering collision objects  which are collidable entity-pairs (collider entity and collidee entity). During <a href="simulation.htm">simulation</a>, the collision state of each registered collision object can then be visualized with a different coloring, or recorded in a graph object. Refer to <a href="graphs.htm">graphs</a> and <a href="dataStreamTypes.htm">graph data stream types</a> for more information about how to record collision states. Registered collision objects are automatically duplicated (copied) if their two composing entities are duplicated simultaneously in a copy-paste operation.<br>
</p>

<p>The collision detection routines used in the collision detection module are also available as stand-alone routines via the <a href="coppeliaGeometricRoutines.htm">Coppelia geometric routines</a>.</p>

<p>The collision detection dialog is part of the <a href="calculationModuleDialog.htm">calculation module properties dialog</a>, which is located at [Menu bar --&gt; Tools --&gt; Calculation module properties]. You can also open the dialog with a click on its <a href="userInterface.htm#toolbars">toolbar</a> button:<br>
</p>

<p align=center><img src="images/calculationModuleButton.jpg"></p>
<p class=imageLabel>[Calculation module properties toolbar button]</p>
<br>

<p>In the calculation module properties dialog, click  the <strong>Collision detection</strong> button to display the collision detection dialog:
</p>

<p align=center><img src="images/collisionDetection3.jpg"></p>
<p class=imageLabel>[Collision detection dialog]</p>
<br>

<li><strong>Enable all collision detections</strong>: allows enabling or disabling collision detection of all registered collision objects.<br>
</li>

<li><strong>Add new collision object</strong>: allows specifying  two entities for collision detection. The list below the button displays all registered collision objects that can be renamed with a double-click. Individual collision objects in the list can be selected, and related properties are then displayed below (see hereafter)..<br>
</li>

<li><strong>Adjust collision color</strong>: allows adjusting the color that a colliding entity will be displayed in. See also the <strong>Collision changes collider color</strong> and <strong>Collision changes collidee color</strong> items further down.<br>
</li>

<li><strong>Explicit handling</strong>: indicates whether the selected collision object should be explicitly handled. If checked, collision detection for this collision object will not be handled when sim.handleCollision(sim.handle_all_except_explicit) is called, but only if sim.handleCollision(sim.handle_all) or sim.handleCollision(collisionObjectHandle) is called. This is useful if the user wishes to handle collision detection for that collision object in a <a href="childScripts.htm">child script</a> rather than in the <a href="mainScript.htm">main script</a> (if not checked, collision detection for that collision object will be handled twice, once when sim.handleCollision(sim.handle_all_except_explicit) is called in the main script, and once when sim.handleCollision(collisionObjectHandle) is called in the child script). Refer also to the section on <a href="explicitHandling.htm">explicit and non-explicit calls</a>.<br>
</li>

<li><strong>Collision changes collider / collidee color</strong>: enables or disables a color change during collision for the collider / collidee entity.<br>
</li>

<li><strong>Comp. coll. contour (shapes only)</strong>: if enabled, then an exhaustive collision detection will be performed for shape-shape collisions: all intersections (i.e. the collision contour) are calculated and visualized. This however requires much more computation time than <em>simple</em> collision detection.<br>
</li>

<li><strong>Adjust contour color</strong>: allows adjusting the color of the collision contour line (see the <strong>Compute collision contour</strong> item above).<br>
</li>

<li><strong>Contour width</strong>: width of the collision contour line (see the <strong>Compute collision contour</strong> item above).<br>
</li>



<br>
<h3 class=recommendedTopics>Recommended topics</h3>

<li><a href="coppeliaGeometricRoutines.htm">Coppelia geometric routines</a></li>
<li><a href="apiFunctionListCategory.htm#collisionObject">Related API functions</a></li>
<li><a href="collidableObjects.htm">Collidable objects</a></li>
<li><a href="objects.htm">Scene objects</a></li>
<li><a href="collections.htm">Collections</a></li>
<br>
<br>
 </tr>
</table> 
</div>  
  
  
</body>

</html>
